package com.wwf.springsession.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @author wwf
 * @date 2020年12月31日 11:27:28
 */
@Controller
@RequestMapping("public")
public class LoginController {
    @RequestMapping("/login")
    public String login(HttpServletRequest request){
        request.setAttribute("context",request.getContextPath());
        return "login";
    }
    @RequestMapping("/doLogin")
    public String doLogin(String username,String psw,HttpServletRequest request){
        Map<String,String> userMap = new HashMap<String,String>();
        userMap.put("username",username);
        userMap.put("psw",psw);
        request.getSession().setAttribute("user",userMap);
        return "redirect:/index/index";
    }
}
